package com.example.cymjoe.huaweishopping;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.TextView;

public class WebVieww extends AppCompatActivity {

    private WebView wv;
    private TextView tt;
    private ImageView ty;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_vieww);
        Intent intent = getIntent();
        String path = intent.getStringExtra("path");
        String name = intent.getStringExtra("name");
        Log.e("ppp",path);

        wv = ((WebView) findViewById(R.id.wv));
        ty = ((ImageView) findViewById(R.id.ty));
        tt = ((TextView) findViewById(R.id.tt));
        tt.setText(name);
        wv.setWebViewClient(new WebViewClient());
        WebSettings settings=wv.getSettings();
        settings.setJavaScriptEnabled(true);

        wv.loadUrl(path);
        ty.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && wv.canGoBack()){
            wv.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
